<?php 

require_once('getconfig.php');

Class Model_generalimage extends Dbo_DbManager
 {
	protected $nslno;
	protected $nid;
	protected $cimagename;
	protected $c_type;

    public function __construct($createCon=TRUE){
 	  parent::__construct($createCon);
 	}
	
	public function getslno()
	{
		return  $this->nslno;
	}	
	public function getuserid()
	{
		return  $this->nid;
	}		
	public function getimagename()
	{
		return  $this->cimagename;
	}	
	public function getpropertyid()
	{
		return  $this->c_type;
	}			
//--------seting-------
	public function setslno($nslno)
	{
		$this->nslno=$nslno;
	}
	public function setuserid($nid)
	{
		$this->nid=$nid;
	}	
	public function setimagename($cimagename)
	{
		$this->cimagename=$cimagename;
	}	
	public function setimagetype($c_type)
	{
		$this->c_type=$c_type;
	}			
									
//---------------------------------------------------------//	
	public function write()
	{
		//echo "haiii";
		$objDbManager = new Dbo_DbManager();
		$intuserid=$objDbManager->write($this);	
	}
	public static function delete($intuserid)
	{
		$objDbManager = new Dbo_DbManager();
		return $objDbManager->remove($intuserid,__CLASS__);
	}


	public static function get($intuserid=NULL)
	{
		$arrRes=array();
		$objDbManager = new Dbo_DbManager();
		$arrModel_generalimage = $objDbManager->fetch(array('intuserid' => $intuserid),__CLASS__);
		if(count($arrModel_generalimage)>0) {
			foreach($arrModel_generalimage as $arrNew) { 
				$objUser = self::build($arrNew);
				$arrRes[]=$objUser;
			}
		}
		return $arrRes;
	}


	public function getoncondition()
	{
		$arrRes=array();
		$objDbManager = new Dbo_DbManager();
		$arrModel_generalimage = $objDbManager->fetchOnCondition($this,TRUE);
		if(count($arrModel_generalimage)>0) {
			foreach($arrModel_generalimage as $arrNew) { 
				$objUser = self::build($arrNew);
				$arrRes[]=$objUser;
			}
		}
		return $arrRes;
	}


	public static function build(array $arrModel_generalimage)
	{
		$Model_generalimage = new Model_generalimage(FALSE);
		@$Model_generalimage->setslno($arrModel_generalimage['nslno']);
		@$Model_generalimage->setuserid($arrModel_generalimage['nid']);
		@$Model_generalimage->setimagename($arrModel_generalimage['cimagename']);
		@$Model_generalimage->setimagetype($arrModel_generalimage['c_type']);
		return $Model_generalimage;
 	 }

     public function getlastinsertedid(){
		$objDbManager = new Dbo_DbManager ();
		$userid=$objDbManager->getMaxId($this,"max","intuserid");
		return $userid;
	}
	
	public static function get_GeneralImage($nid){
	
		$arrRes=array();
		$objDbManager = new Dbo_DbManager ();
		$qry="SELECT * FROM generalimage WHERE nid='$nid'";
		//echo $qry;
		$arrModel_generalimage=$objDbManager->runquery("$qry");
		if (count( $arrModel_generalimage ) > 0) {
			foreach ( $arrModel_generalimage as $arrNew ) {
				$objUser = self::build( $arrNew );
				$arrRes [] = $objUser;
			}
		}
		return $arrRes;
	}
	
	
    public  function __call($method, $arguments) {
    	
       if(count($arguments)>0){
       	   $sqlFunction=$arguments[0];
       	    $objDbManager = new Dbo_DbManager();
       	   return $objDbManager->runSqlFunctions(__CLASS__,array($method=>$sqlFunction));
       }
    }
 
	

 }
 ?>
